<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP                  #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude    #-}</span><span>
</span><span id="line-3"></span><span class="hs-comment">{- |
   Module      :  System.Win32.Encoding
   Copyright   :  2012 shelarcy
   License     :  BSD-style

   Maintainer  :  shelarcy@gmail.com
   Stability   :  Provisional
   Portability :  Non-portable (Win32 API)

   Enocode/Decode mutibyte charactor using Win32 API.
-}</span><span>
</span><span id="line-14"></span><span>
</span><span id="line-15"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IO.Windows.Encoding</span><span>
</span><span id="line-16"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByte"><span class="hs-identifier">encodeMultiByte</span></a></span><span>
</span><span id="line-17"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO"><span class="hs-identifier">encodeMultiByteIO</span></a></span><span>
</span><span id="line-18"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteRawIO"><span class="hs-identifier">encodeMultiByteRawIO</span></a></span><span>
</span><span id="line-19"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#decodeMultiByte"><span class="hs-identifier">decodeMultiByte</span></a></span><span>
</span><span id="line-20"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#decodeMultiByteIO"><span class="hs-identifier">decodeMultiByteIO</span></a></span><span>
</span><span id="line-21"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#wideCharToMultiByte"><span class="hs-identifier">wideCharToMultiByte</span></a></span><span>
</span><span id="line-22"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#multiByteToWideChar"><span class="hs-identifier">multiByteToWideChar</span></a></span><span>
</span><span id="line-23"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#withGhcInternalToUTF16"><span class="hs-identifier">withGhcInternalToUTF16</span></a></span><span>
</span><span id="line-24"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#withUTF16ToGhcInternal"><span class="hs-identifier">withUTF16ToGhcInternal</span></a></span><span>
</span><span id="line-25"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Word.html"><span class="hs-identifier">Data.Word</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier">Word8</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Word.html#Word16"><span class="hs-identifier">Word16</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.Types.html"><span class="hs-identifier">Foreign.C.Types</span></a></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier">CInt</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.String.html"><span class="hs-identifier">Foreign.C.String</span></a></span><span>       </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.C.String.html#peekCAStringLen"><span class="hs-identifier">peekCAStringLen</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.C.String.html#peekCWStringLen"><span class="hs-identifier">peekCWStringLen</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>                               </span><span class="annot"><a href="Foreign.C.String.html#withCWStringLen"><span class="hs-identifier">withCWStringLen</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.C.String.html#withCAStringLen"><span class="hs-identifier">withCAStringLen</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Ptr.html"><span class="hs-identifier">Foreign.Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier">nullPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Marshal.Array.html"><span class="hs-identifier">Foreign.Marshal.Array</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier">allocaArray</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Marshal.Unsafe.html"><span class="hs-identifier">Foreign.Marshal.Unsafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Marshal.Unsafe.html#unsafeLocalState"><span class="hs-identifier">unsafeLocalState</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Windows.html"><span class="hs-identifier">GHC.Windows</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html"><span class="hs-identifier">GHC.IO.Encoding.CodePage</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier">CodePage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#getCurrentCodePage"><span class="hs-identifier">getCurrentCodePage</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.html"><span class="hs-identifier">GHC.IO</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Real.html"><span class="hs-identifier">GHC.Real</span></a></span><span class="hs-cpp">

#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- | The &quot;System.IO&quot; output functions (e.g. `putStr`) don't</span><span>
</span><span id="line-43"></span><span class="hs-comment">-- automatically convert to multibyte string on Windows, so this</span><span>
</span><span id="line-44"></span><span class="hs-comment">-- function is provided to make the conversion from a Unicode string</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- in the given code page to a proper multibyte string.  To get the</span><span>
</span><span id="line-46"></span><span class="hs-comment">-- code page for the console, use `getCurrentCodePage`.</span><span>
</span><span id="line-47"></span><span class="hs-comment">--</span><span>
</span><span id="line-48"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByte"><span class="hs-identifier hs-type">encodeMultiByte</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-49"></span><span id="encodeMultiByte"><span class="annot"><span class="annottext">encodeMultiByte :: DWORD -&gt; String -&gt; String
</span><a href="GHC.IO.Windows.Encoding.html#encodeMultiByte"><span class="hs-identifier hs-var hs-var">encodeMultiByte</span></a></span></span><span> </span><span id="local-6989586621679544400"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544400"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO String -&gt; String
forall a. IO a -&gt; a
</span><a href="Foreign.Marshal.Unsafe.html#unsafeLocalState"><span class="hs-identifier hs-var">unsafeLocalState</span></a></span><span> </span><span class="annot"><span class="annottext">(IO String -&gt; String) -&gt; (String -&gt; IO String) -&gt; String -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; String -&gt; IO String
</span><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO"><span class="hs-identifier hs-var">encodeMultiByteIO</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544400"><span class="hs-identifier hs-var">cp</span></a></span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO%27"><span class="hs-pragma hs-type">encodeMultiByteIO'</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- | String must not be zero length.</span><span>
</span><span id="line-53"></span><span id="local-6989586621679544514"><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO%27"><span class="hs-identifier hs-type">encodeMultiByteIO'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Windows.html#LPCSTR"><span class="hs-identifier hs-type">LPCSTR</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679544514"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679544514"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-54"></span><span id="encodeMultiByteIO%27"><span class="annot"><span class="annottext">encodeMultiByteIO' :: forall a. DWORD -&gt; String -&gt; ((LPCSTR, CInt) -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO%27"><span class="hs-identifier hs-var hs-var">encodeMultiByteIO'</span></a></span></span><span> </span><span id="local-6989586621679544378"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544378"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span id="local-6989586621679544377"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679544377"><span class="hs-identifier hs-var">wstr</span></a></span></span><span> </span><span id="local-6989586621679544376"><span class="annot"><span class="annottext">(LPCSTR, CInt) -&gt; IO a
</span><a href="#local-6989586621679544376"><span class="hs-identifier hs-var">transformer</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-55"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; (CWStringLen -&gt; IO a) -&gt; IO a
forall a. String -&gt; (CWStringLen -&gt; IO a) -&gt; IO a
</span><a href="Foreign.C.String.html#withCWStringLen"><span class="hs-identifier hs-var">withCWStringLen</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679544377"><span class="hs-identifier hs-var">wstr</span></a></span><span> </span><span class="annot"><span class="annottext">((CWStringLen -&gt; IO a) -&gt; IO a) -&gt; (CWStringLen -&gt; IO a) -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679544375"><span class="annot"><span class="annottext">Ptr CWchar
</span><a href="#local-6989586621679544375"><span class="hs-identifier hs-var">cwstr</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679544374"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544374"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-56"></span><span>    </span><span id="local-6989586621679544373"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544373"><span class="hs-identifier hs-var">mbchars'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-var">failIfZero</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;WideCharToMultiByte&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
-&gt; DWORD
-&gt; Ptr CWchar
-&gt; CInt
-&gt; LPCSTR
-&gt; CInt
-&gt; LPCSTR
-&gt; LPBOOL
-&gt; IO CInt
</span><a href="GHC.IO.Windows.Encoding.html#wideCharToMultiByte"><span class="hs-identifier hs-var">wideCharToMultiByte</span></a></span><span>
</span><span id="line-57"></span><span>                </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544378"><span class="hs-identifier hs-var">cp</span></a></span><span>
</span><span id="line-58"></span><span>                </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span>
</span><span id="line-59"></span><span>                </span><span class="annot"><span class="annottext">Ptr CWchar
</span><a href="#local-6989586621679544375"><span class="hs-identifier hs-var">cwstr</span></a></span><span>
</span><span id="line-60"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544374"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span>                </span><span class="annot"><span class="annottext">LPCSTR
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span>
</span><span id="line-62"></span><span>                </span><span class="annot"><span class="annottext">LPCSTR
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">LPBOOL
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-63"></span><span>    </span><span class="hs-comment">-- mbchar' is the length of buffer required</span><span>
</span><span id="line-64"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; (LPCSTR -&gt; IO a) -&gt; IO a
forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier hs-var">allocaArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544373"><span class="hs-identifier hs-var">mbchars'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((LPCSTR -&gt; IO a) -&gt; IO a) -&gt; (LPCSTR -&gt; IO a) -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679544371"><span class="annot"><span class="annottext">LPCSTR
</span><a href="#local-6989586621679544371"><span class="hs-identifier hs-var">mbstr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-65"></span><span>      </span><span id="local-6989586621679544370"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544370"><span class="hs-identifier hs-var">mbchars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-var">failIfZero</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;WideCharToMultiByte&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
-&gt; DWORD
-&gt; Ptr CWchar
-&gt; CInt
-&gt; LPCSTR
-&gt; CInt
-&gt; LPCSTR
-&gt; LPBOOL
-&gt; IO CInt
</span><a href="GHC.IO.Windows.Encoding.html#wideCharToMultiByte"><span class="hs-identifier hs-var">wideCharToMultiByte</span></a></span><span>
</span><span id="line-66"></span><span>                 </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544378"><span class="hs-identifier hs-var">cp</span></a></span><span>
</span><span id="line-67"></span><span>                 </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span>
</span><span id="line-68"></span><span>                 </span><span class="annot"><span class="annottext">Ptr CWchar
</span><a href="#local-6989586621679544375"><span class="hs-identifier hs-var">cwstr</span></a></span><span>
</span><span id="line-69"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544374"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-70"></span><span>                 </span><span class="annot"><span class="annottext">LPCSTR
</span><a href="#local-6989586621679544371"><span class="hs-identifier hs-var">mbstr</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544373"><span class="hs-identifier hs-var">mbchars'</span></a></span><span>
</span><span id="line-71"></span><span>                 </span><span class="annot"><span class="annottext">LPCSTR
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">LPBOOL
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-72"></span><span>      </span><span class="annot"><span class="annottext">(LPCSTR, CInt) -&gt; IO a
</span><a href="#local-6989586621679544376"><span class="hs-identifier hs-var">transformer</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LPCSTR
</span><a href="#local-6989586621679544371"><span class="hs-identifier hs-var">mbstr</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CInt -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544370"><span class="hs-identifier hs-var">mbchars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-comment">-- converts [Char] to UTF-16</span><span>
</span><span id="line-75"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO"><span class="hs-identifier hs-type">encodeMultiByteIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-76"></span><span id="encodeMultiByteIO"><span class="annot"><span class="annottext">encodeMultiByteIO :: DWORD -&gt; String -&gt; IO String
</span><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO"><span class="hs-identifier hs-var hs-var">encodeMultiByteIO</span></a></span></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span>
</span><span id="line-77"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO"><span class="hs-identifier hs-var">encodeMultiByteIO</span></a></span><span> </span><span id="local-6989586621679544369"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544369"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span id="local-6989586621679544368"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679544368"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; String -&gt; ((LPCSTR, CInt) -&gt; IO String) -&gt; IO String
forall a. DWORD -&gt; String -&gt; ((LPCSTR, CInt) -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO%27"><span class="hs-identifier hs-var">encodeMultiByteIO'</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544369"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679544368"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">(LPCSTR, CInt) -&gt; IO String
forall {a}. Integral a =&gt; (LPCSTR, a) -&gt; IO String
</span><a href="#local-6989586621679544367"><span class="hs-identifier hs-var">toString</span></a></span><span>
</span><span id="line-78"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679544367"><span class="annot"><span class="annottext">toString :: (LPCSTR, a) -&gt; IO String
</span><a href="#local-6989586621679544367"><span class="hs-identifier hs-var hs-var">toString</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679544363"><span class="annot"><span class="annottext">LPCSTR
</span><a href="#local-6989586621679544363"><span class="hs-identifier hs-var">st</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679544362"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679544362"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CStringLen -&gt; IO String
</span><a href="Foreign.C.String.html#peekCAStringLen"><span class="hs-identifier hs-var">peekCAStringLen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LPCSTR
</span><a href="#local-6989586621679544363"><span class="hs-identifier hs-var">st</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">a -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679544362"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span class="hs-comment">-- converts [Char] to UTF-16</span><span>
</span><span id="line-81"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteRawIO"><span class="hs-identifier hs-type">encodeMultiByteRawIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Windows.html#LPCSTR"><span class="hs-identifier hs-type">LPCSTR</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-82"></span><span id="encodeMultiByteRawIO"><span class="annot"><span class="annottext">encodeMultiByteRawIO :: DWORD -&gt; String -&gt; IO (LPCSTR, CInt)
</span><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteRawIO"><span class="hs-identifier hs-var hs-var">encodeMultiByteRawIO</span></a></span></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LPCSTR, CInt) -&gt; IO (LPCSTR, CInt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LPCSTR
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteRawIO"><span class="hs-identifier hs-var">encodeMultiByteRawIO</span></a></span><span> </span><span id="local-6989586621679544361"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544361"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span id="local-6989586621679544360"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679544360"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD
-&gt; String
-&gt; ((LPCSTR, CInt) -&gt; IO (LPCSTR, CInt))
-&gt; IO (LPCSTR, CInt)
forall a. DWORD -&gt; String -&gt; ((LPCSTR, CInt) -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Windows.Encoding.html#encodeMultiByteIO%27"><span class="hs-identifier hs-var">encodeMultiByteIO'</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544361"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679544360"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">(LPCSTR, CInt) -&gt; IO (LPCSTR, CInt)
forall {m :: * -&gt; *} {a} {b} {a}.
(Monad m, Integral a, Num b) =&gt;
(a, a) -&gt; m (a, b)
</span><a href="#local-6989586621679544359"><span class="hs-identifier hs-var">toSizedCString</span></a></span><span>
</span><span id="line-84"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679544359"><span class="annot"><span class="annottext">toSizedCString :: (a, a) -&gt; m (a, b)
</span><a href="#local-6989586621679544359"><span class="hs-identifier hs-var hs-var">toSizedCString</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679544352"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679544352"><span class="hs-identifier hs-var">st</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679544351"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679544351"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a, b) -&gt; m (a, b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679544352"><span class="hs-identifier hs-var">st</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a -&gt; b
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679544351"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;WideCharToMultiByte&quot;</span><span>
</span><span id="line-87"></span><span>  </span><span id="wideCharToMultiByte"><span class="annot"><a href="GHC.IO.Windows.Encoding.html#wideCharToMultiByte"><span class="hs-identifier hs-var">wideCharToMultiByte</span></a></span></span><span>
</span><span id="line-88"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span>
</span><span id="line-89"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span>   </span><span class="hs-comment">-- dwFlags,</span><span>
</span><span id="line-90"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPCWSTR"><span class="hs-identifier hs-type">LPCWSTR</span></a></span><span> </span><span class="hs-comment">-- lpWideCharStr</span><span>
</span><span id="line-91"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>    </span><span class="hs-comment">-- cchWideChar</span><span>
</span><span id="line-92"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPSTR"><span class="hs-identifier hs-type">LPSTR</span></a></span><span>   </span><span class="hs-comment">-- lpMultiByteStr</span><span>
</span><span id="line-93"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>    </span><span class="hs-comment">-- cbMultiByte</span><span>
</span><span id="line-94"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPCSTR"><span class="hs-identifier hs-type">LPCSTR</span></a></span><span>  </span><span class="hs-comment">-- lpMultiByteStr</span><span>
</span><span id="line-95"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPBOOL"><span class="hs-identifier hs-type">LPBOOL</span></a></span><span>  </span><span class="hs-comment">-- lpbFlags</span><span>
</span><span id="line-96"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-97"></span><span>
</span><span id="line-98"></span><span class="hs-comment">-- | The `System.IO` input functions (e.g. `getLine`) don't</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- automatically convert to Unicode, so this function is provided to</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- make the conversion from a multibyte string in the given code page</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- to a proper Unicode string.  To get the code page for the console,</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- use `getConsoleCP`.</span><span>
</span><span id="line-103"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#stringToUnicode"><span class="hs-identifier hs-type">stringToUnicode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-104"></span><span id="stringToUnicode"><span class="annot"><span class="annottext">stringToUnicode :: DWORD -&gt; String -&gt; IO String
</span><a href="GHC.IO.Windows.Encoding.html#stringToUnicode"><span class="hs-identifier hs-var hs-var">stringToUnicode</span></a></span></span><span> </span><span id="local-6989586621679544347"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544347"><span class="hs-identifier hs-var">_cp</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span>
</span><span id="line-105"></span><span>     </span><span class="hs-comment">-- MultiByteToWideChar doesn't handle empty strings (#1929)</span><span>
</span><span id="line-106"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#stringToUnicode"><span class="hs-identifier hs-var">stringToUnicode</span></a></span><span> </span><span id="local-6989586621679544346"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544346"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span id="local-6989586621679544345"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679544345"><span class="hs-identifier hs-var">mbstr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-107"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; (CStringLen -&gt; IO String) -&gt; IO String
forall a. String -&gt; (CStringLen -&gt; IO a) -&gt; IO a
</span><a href="Foreign.C.String.html#withCAStringLen"><span class="hs-identifier hs-var">withCAStringLen</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679544345"><span class="hs-identifier hs-var">mbstr</span></a></span><span> </span><span class="annot"><span class="annottext">((CStringLen -&gt; IO String) -&gt; IO String)
-&gt; (CStringLen -&gt; IO String) -&gt; IO String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679544344"><span class="annot"><span class="annottext">LPCSTR
</span><a href="#local-6989586621679544344"><span class="hs-identifier hs-var">cstr</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679544343"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544343"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-108"></span><span>    </span><span id="local-6989586621679544342"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544342"><span class="hs-identifier hs-var">wchars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-var">failIfZero</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;MultiByteToWideChar&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; DWORD -&gt; LPCSTR -&gt; CInt -&gt; Ptr CWchar -&gt; CInt -&gt; IO CInt
</span><a href="GHC.IO.Windows.Encoding.html#multiByteToWideChar"><span class="hs-identifier hs-var">multiByteToWideChar</span></a></span><span>
</span><span id="line-109"></span><span>                </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544346"><span class="hs-identifier hs-var">cp</span></a></span><span>
</span><span id="line-110"></span><span>                </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span>
</span><span id="line-111"></span><span>                </span><span class="annot"><span class="annottext">LPCSTR
</span><a href="#local-6989586621679544344"><span class="hs-identifier hs-var">cstr</span></a></span><span>
</span><span id="line-112"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544343"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-113"></span><span>                </span><span class="annot"><span class="annottext">Ptr CWchar
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span>
</span><span id="line-114"></span><span>    </span><span class="hs-comment">-- wchars is the length of buffer required</span><span>
</span><span id="line-115"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; (Ptr CWchar -&gt; IO String) -&gt; IO String
forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier hs-var">allocaArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544342"><span class="hs-identifier hs-var">wchars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Ptr CWchar -&gt; IO String) -&gt; IO String)
-&gt; (Ptr CWchar -&gt; IO String) -&gt; IO String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679544341"><span class="annot"><span class="annottext">Ptr CWchar
</span><a href="#local-6989586621679544341"><span class="hs-identifier hs-var">cwstr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-116"></span><span>      </span><span id="local-6989586621679544340"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544340"><span class="hs-identifier hs-var">wchars'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-var">failIfZero</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;MultiByteToWideChar&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; DWORD -&gt; LPCSTR -&gt; CInt -&gt; Ptr CWchar -&gt; CInt -&gt; IO CInt
</span><a href="GHC.IO.Windows.Encoding.html#multiByteToWideChar"><span class="hs-identifier hs-var">multiByteToWideChar</span></a></span><span>
</span><span id="line-117"></span><span>                </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544346"><span class="hs-identifier hs-var">cp</span></a></span><span>
</span><span id="line-118"></span><span>                </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span>
</span><span id="line-119"></span><span>                </span><span class="annot"><span class="annottext">LPCSTR
</span><a href="#local-6989586621679544344"><span class="hs-identifier hs-var">cstr</span></a></span><span>
</span><span id="line-120"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544343"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-121"></span><span>                </span><span class="annot"><span class="annottext">Ptr CWchar
</span><a href="#local-6989586621679544341"><span class="hs-identifier hs-var">cwstr</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544342"><span class="hs-identifier hs-var">wchars</span></a></span><span>
</span><span id="line-122"></span><span>      </span><span class="annot"><span class="annottext">CWStringLen -&gt; IO String
</span><a href="Foreign.C.String.html#peekCWStringLen"><span class="hs-identifier hs-var">peekCWStringLen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr CWchar
</span><a href="#local-6989586621679544341"><span class="hs-identifier hs-var">cwstr</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544340"><span class="hs-identifier hs-var">wchars'</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- converts UTF-16 to [Char]</span><span>
</span><span id="line-123"></span><span>
</span><span id="line-124"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;MultiByteToWideChar&quot;</span><span>
</span><span id="line-125"></span><span>  </span><span id="multiByteToWideChar"><span class="annot"><a href="GHC.IO.Windows.Encoding.html#multiByteToWideChar"><span class="hs-identifier hs-var">multiByteToWideChar</span></a></span></span><span>
</span><span id="line-126"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span>
</span><span id="line-127"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span>   </span><span class="hs-comment">-- dwFlags,</span><span>
</span><span id="line-128"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPCSTR"><span class="hs-identifier hs-type">LPCSTR</span></a></span><span>  </span><span class="hs-comment">-- lpMultiByteStr</span><span>
</span><span id="line-129"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>    </span><span class="hs-comment">-- cbMultiByte</span><span>
</span><span id="line-130"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPWSTR"><span class="hs-identifier hs-type">LPWSTR</span></a></span><span>  </span><span class="hs-comment">-- lpWideCharStr</span><span>
</span><span id="line-131"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>    </span><span class="hs-comment">-- cchWideChar</span><span>
</span><span id="line-132"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#decodeMultiByte"><span class="hs-identifier hs-type">decodeMultiByte</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-135"></span><span id="decodeMultiByte"><span class="annot"><span class="annottext">decodeMultiByte :: DWORD -&gt; String -&gt; String
</span><a href="GHC.IO.Windows.Encoding.html#decodeMultiByte"><span class="hs-identifier hs-var hs-var">decodeMultiByte</span></a></span></span><span> </span><span id="local-6989586621679544338"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544338"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO String -&gt; String
forall a. IO a -&gt; a
</span><a href="Foreign.Marshal.Unsafe.html#unsafeLocalState"><span class="hs-identifier hs-var">unsafeLocalState</span></a></span><span> </span><span class="annot"><span class="annottext">(IO String -&gt; String) -&gt; (String -&gt; IO String) -&gt; String -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; String -&gt; IO String
</span><a href="GHC.IO.Windows.Encoding.html#decodeMultiByteIO"><span class="hs-identifier hs-var">decodeMultiByteIO</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544338"><span class="hs-identifier hs-var">cp</span></a></span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span class="hs-comment">-- | Because of `stringToUnicode` is unclear name, we use `decodeMultiByteIO`</span><span>
</span><span id="line-138"></span><span class="hs-comment">-- for alias of `stringToUnicode`.</span><span>
</span><span id="line-139"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#decodeMultiByteIO"><span class="hs-identifier hs-type">decodeMultiByteIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-140"></span><span id="decodeMultiByteIO"><span class="annot"><span class="annottext">decodeMultiByteIO :: DWORD -&gt; String -&gt; IO String
</span><a href="GHC.IO.Windows.Encoding.html#decodeMultiByteIO"><span class="hs-identifier hs-var hs-var">decodeMultiByteIO</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; String -&gt; IO String
</span><a href="GHC.IO.Windows.Encoding.html#stringToUnicode"><span class="hs-identifier hs-var">stringToUnicode</span></a></span><span>
</span><span id="line-141"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#decodeMultiByteIO"><span class="hs-pragma hs-type">decodeMultiByteIO</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;MultiByteToWideChar&quot;</span><span>
</span><span id="line-144"></span><span>  </span><span id="multiByteToWideChar%27"><span class="annot"><a href="GHC.IO.Windows.Encoding.html#multiByteToWideChar%27"><span class="hs-identifier hs-var">multiByteToWideChar'</span></a></span></span><span>
</span><span id="line-145"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span>
</span><span id="line-146"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span>   </span><span class="hs-comment">-- dwFlags,</span><span>
</span><span id="line-147"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>  </span><span class="hs-comment">-- lpMultiByteStr</span><span>
</span><span id="line-148"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>    </span><span class="hs-comment">-- cbMultiByte</span><span>
</span><span id="line-149"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span>  </span><span class="hs-comment">-- lpWideCharStr</span><span>
</span><span id="line-150"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>    </span><span class="hs-comment">-- cchWideChar</span><span>
</span><span id="line-151"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="hs-comment">-- TODO: GHC is internally UTF-32 which means we have re-encode for</span><span>
</span><span id="line-154"></span><span class="hs-comment">--       Windows which is annoying. Switch to UTF-16 on IoNative</span><span>
</span><span id="line-155"></span><span class="hs-comment">--       being default.</span><span>
</span><span id="line-156"></span><span id="local-6989586621679544490"><span class="annot"><a href="GHC.IO.Windows.Encoding.html#withGhcInternalToUTF16"><span class="hs-identifier hs-type">withGhcInternalToUTF16</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679544490"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-157"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679544490"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-158"></span><span id="withGhcInternalToUTF16"><span class="annot"><span class="annottext">withGhcInternalToUTF16 :: forall a. Ptr Word8 -&gt; Int -&gt; ((Ptr Word16, CInt) -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Windows.Encoding.html#withGhcInternalToUTF16"><span class="hs-identifier hs-var hs-var">withGhcInternalToUTF16</span></a></span></span><span> </span><span id="local-6989586621679544319"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679544319"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679544318"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544318"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621679544317"><span class="annot"><span class="annottext">(Ptr Word16, CInt) -&gt; IO a
</span><a href="#local-6989586621679544317"><span class="hs-identifier hs-var">fn</span></a></span></span><span>
</span><span id="line-159"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679544316"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544316"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO DWORD
</span><a href="GHC.IO.Encoding.CodePage.html#getCurrentCodePage"><span class="hs-identifier hs-var">getCurrentCodePage</span></a></span><span>
</span><span id="line-160"></span><span>      </span><span id="local-6989586621679544315"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544315"><span class="hs-identifier hs-var">wchars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-var">failIfZero</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;withGhcInternalToUTF16&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-161"></span><span>                  </span><span class="annot"><span class="annottext">DWORD
-&gt; DWORD -&gt; Ptr Word8 -&gt; CInt -&gt; Ptr Word16 -&gt; CInt -&gt; IO CInt
</span><a href="GHC.IO.Windows.Encoding.html#multiByteToWideChar%27"><span class="hs-identifier hs-var">multiByteToWideChar'</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544316"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679544319"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544318"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word16
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span>
</span><span id="line-162"></span><span>      </span><span class="hs-comment">-- wchars is the length of buffer required</span><span>
</span><span id="line-163"></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word16 -&gt; IO a) -&gt; IO a
forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier hs-var">allocaArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544315"><span class="hs-identifier hs-var">wchars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Ptr Word16 -&gt; IO a) -&gt; IO a) -&gt; (Ptr Word16 -&gt; IO a) -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679544314"><span class="annot"><span class="annottext">Ptr Word16
</span><a href="#local-6989586621679544314"><span class="hs-identifier hs-var">cwstr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-164"></span><span>        </span><span id="local-6989586621679544313"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544313"><span class="hs-identifier hs-var">wchars'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-var">failIfZero</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;withGhcInternalToUTF16&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-165"></span><span>                    </span><span class="annot"><span class="annottext">DWORD
-&gt; DWORD -&gt; Ptr Word8 -&gt; CInt -&gt; Ptr Word16 -&gt; CInt -&gt; IO CInt
</span><a href="GHC.IO.Windows.Encoding.html#multiByteToWideChar%27"><span class="hs-identifier hs-var">multiByteToWideChar'</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544316"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679544319"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544318"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word16
</span><a href="#local-6989586621679544314"><span class="hs-identifier hs-var">cwstr</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544315"><span class="hs-identifier hs-var">wchars</span></a></span><span>
</span><span id="line-166"></span><span>        </span><span class="annot"><span class="annottext">(Ptr Word16, CInt) -&gt; IO a
</span><a href="#local-6989586621679544317"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word16
</span><a href="#local-6989586621679544314"><span class="hs-identifier hs-var">cwstr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544313"><span class="hs-identifier hs-var">wchars'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;WideCharToMultiByte&quot;</span><span>
</span><span id="line-169"></span><span>  </span><span id="wideCharToMultiByte%27"><span class="annot"><a href="GHC.IO.Windows.Encoding.html#wideCharToMultiByte%27"><span class="hs-identifier hs-var">wideCharToMultiByte'</span></a></span></span><span>
</span><span id="line-170"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html#CodePage"><span class="hs-identifier hs-type">CodePage</span></a></span><span>
</span><span id="line-171"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span>   </span><span class="hs-comment">-- dwFlags,</span><span>
</span><span id="line-172"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="hs-comment">-- lpWideCharStr</span><span>
</span><span id="line-173"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>    </span><span class="hs-comment">-- cchWideChar</span><span>
</span><span id="line-174"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>   </span><span class="hs-comment">-- lpMultiByteStr</span><span>
</span><span id="line-175"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>    </span><span class="hs-comment">-- cbMultiByte</span><span>
</span><span id="line-176"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPCSTR"><span class="hs-identifier hs-type">LPCSTR</span></a></span><span>  </span><span class="hs-comment">-- lpMultiByteStr</span><span>
</span><span id="line-177"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPBOOL"><span class="hs-identifier hs-type">LPBOOL</span></a></span><span>  </span><span class="hs-comment">-- lpbFlags</span><span>
</span><span id="line-178"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span class="hs-comment">-- TODO: GHC is internally UTF-32 which means we have re-encode for</span><span>
</span><span id="line-181"></span><span class="hs-comment">--       Windows which is annoying. Switch to UTF-16 on IoNative</span><span>
</span><span id="line-182"></span><span class="hs-comment">--       being default.</span><span>
</span><span id="line-183"></span><span>
</span><span id="line-184"></span><span class="hs-comment">-- | Decode a UTF16 buffer into the given buffer in the current code page.</span><span>
</span><span id="line-185"></span><span class="hs-comment">-- The source UTF16 buffer is filled by the function given as argument.</span><span>
</span><span id="line-186"></span><span class="annot"><a href="GHC.IO.Windows.Encoding.html#withUTF16ToGhcInternal"><span class="hs-identifier hs-type">withUTF16ToGhcInternal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-comment">-- Buffer to store the encoded string in.</span><span>
</span><span id="line-187"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>       </span><span class="hs-comment">-- Length of the buffer</span><span>
</span><span id="line-188"></span><span>                       </span><span class="hs-comment">-- Function to fill source buffer.</span><span>
</span><span id="line-189"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>       </span><span class="hs-comment">-- Size of available buffer in bytes</span><span>
</span><span id="line-190"></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="hs-comment">-- Temporary source buffer.</span><span>
</span><span id="line-191"></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>    </span><span class="hs-comment">-- Actual length of buffer content.</span><span>
</span><span id="line-192"></span><span>                           </span><span class="hs-special">)</span><span>
</span><span id="line-193"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>    </span><span class="hs-comment">-- Returns number of bytes stored in buffer.</span><span>
</span><span id="line-194"></span><span id="withUTF16ToGhcInternal"><span class="annot"><span class="annottext">withUTF16ToGhcInternal :: Ptr Word8 -&gt; Int -&gt; (CInt -&gt; Ptr Word16 -&gt; IO CInt) -&gt; IO Int
</span><a href="GHC.IO.Windows.Encoding.html#withUTF16ToGhcInternal"><span class="hs-identifier hs-var hs-var">withUTF16ToGhcInternal</span></a></span></span><span> </span><span id="local-6989586621679544311"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679544311"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679544310"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544310"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621679544309"><span class="annot"><span class="annottext">CInt -&gt; Ptr Word16 -&gt; IO CInt
</span><a href="#local-6989586621679544309"><span class="hs-identifier hs-var">fn</span></a></span></span><span>
</span><span id="line-195"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679544308"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544308"><span class="hs-identifier hs-var">cp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO DWORD
</span><a href="GHC.IO.Encoding.CodePage.html#getCurrentCodePage"><span class="hs-identifier hs-var">getCurrentCodePage</span></a></span><span>
</span><span id="line-196"></span><span>      </span><span class="hs-comment">-- Annoyingly the IO system is very UTF-32 oriented and asks for bytes</span><span>
</span><span id="line-197"></span><span>      </span><span class="hs-comment">-- as buffer reads.  Problem is we don't know how many bytes we'll end up</span><span>
</span><span id="line-198"></span><span>      </span><span class="hs-comment">-- having as UTF-32 MultiByte encoded UTF-16. So be conservative.  We assume</span><span>
</span><span id="line-199"></span><span>      </span><span class="hs-comment">-- that a single byte may expand to atmost 1 Word16.  So assume that each</span><span>
</span><span id="line-200"></span><span>      </span><span class="hs-comment">-- byte does and divide the requested number of bytes by two since each</span><span>
</span><span id="line-201"></span><span>      </span><span class="hs-comment">-- Word16 encoded wchar may expand to only two Word8 sequences.</span><span>
</span><span id="line-202"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679544303"><span class="annot"><span class="annottext">reqBytes :: Int
</span><a href="#local-6989586621679544303"><span class="hs-identifier hs-var hs-var">reqBytes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544310"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Integral a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Real.html#div"><span class="hs-operator hs-var">`div`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span>
</span><span id="line-203"></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word16 -&gt; IO Int) -&gt; IO Int
forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier hs-var">allocaArray</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544303"><span class="hs-identifier hs-var">reqBytes</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word16 -&gt; IO Int) -&gt; IO Int)
-&gt; (Ptr Word16 -&gt; IO Int) -&gt; IO Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679544301"><span class="annot"><span class="annottext">Ptr Word16
</span><a href="#local-6989586621679544301"><span class="hs-identifier hs-var">w_ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-204"></span><span>        </span><span id="local-6989586621679544300"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544300"><span class="hs-identifier hs-var">w_len</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Ptr Word16 -&gt; IO CInt
</span><a href="#local-6989586621679544309"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544303"><span class="hs-identifier hs-var">reqBytes</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word16
</span><a href="#local-6989586621679544301"><span class="hs-identifier hs-var">w_ptr</span></a></span><span>
</span><span id="line-205"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544300"><span class="hs-identifier hs-var">w_len</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span>
</span><span id="line-206"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-207"></span><span>                </span><span class="hs-comment">-- Get required length of encoding</span><span>
</span><span id="line-208"></span><span>                </span><span id="local-6989586621679544299"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544299"><span class="hs-identifier hs-var">mbchars'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-var">failIfZero</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;withUTF16ToGhcInternal&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-209"></span><span>                              </span><span class="annot"><span class="annottext">DWORD
-&gt; DWORD
-&gt; Ptr Word16
-&gt; CInt
-&gt; Ptr Word8
-&gt; CInt
-&gt; LPCSTR
-&gt; LPBOOL
-&gt; IO CInt
</span><a href="GHC.IO.Windows.Encoding.html#wideCharToMultiByte%27"><span class="hs-identifier hs-var">wideCharToMultiByte'</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544308"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word16
</span><a href="#local-6989586621679544301"><span class="hs-identifier hs-var">w_ptr</span></a></span><span>
</span><span id="line-210"></span><span>                                                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544300"><span class="hs-identifier hs-var">w_len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-211"></span><span>                                                  </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">LPCSTR
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">LPBOOL
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-212"></span><span>                </span><span class="annot"><span class="annottext">Bool -&gt; IO Int -&gt; IO Int
forall a. (?callStack::CallStack) =&gt; Bool -&gt; a -&gt; a
</span><a href="GHC.Base.html#assert"><span class="hs-identifier hs-var hs-var">assert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544299"><span class="hs-identifier hs-var">mbchars'</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679544310"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO Int -&gt; IO Int) -&gt; IO Int -&gt; IO Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-213"></span><span>                  </span><span class="hs-comment">-- mbchar' is the length of buffer required</span><span>
</span><span id="line-214"></span><span>                  </span><span id="local-6989586621679544297"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544297"><span class="hs-identifier hs-var">mbchars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-var">failIfZero</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;withUTF16ToGhcInternal&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-215"></span><span>                                </span><span class="annot"><span class="annottext">DWORD
-&gt; DWORD
-&gt; Ptr Word16
-&gt; CInt
-&gt; Ptr Word8
-&gt; CInt
-&gt; LPCSTR
-&gt; LPBOOL
-&gt; IO CInt
</span><a href="GHC.IO.Windows.Encoding.html#wideCharToMultiByte%27"><span class="hs-identifier hs-var">wideCharToMultiByte'</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679544308"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word16
</span><a href="#local-6989586621679544301"><span class="hs-identifier hs-var">w_ptr</span></a></span><span>
</span><span id="line-216"></span><span>                                                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544300"><span class="hs-identifier hs-var">w_len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679544311"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-217"></span><span>                                                    </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544299"><span class="hs-identifier hs-var">mbchars'</span></a></span><span> </span><span class="annot"><span class="annottext">LPCSTR
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">LPBOOL
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-218"></span><span>                  </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; IO Int) -&gt; Int -&gt; IO Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679544297"><span class="hs-identifier hs-var">mbchars</span></a></span><span>
</span><span id="line-219"></span></pre></body></html>